<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">
        <button @click="handleClick1">click1</button>
        <button @click="handleClick2">click2</button>
        <button @click="handleClick3">click3</button>
        {{ myData }}
        <br>
        同名函数执行自己vue中的函数：{{ fn() }}
    </div>
    <script src='./js/vue.js'></script>
    <script>
        var obj = {
            methods: {
                handleClick1() {
                    console.log("click1")
                },
                handleClick2() {
                    console.log("click2")
                },
                fn() {
                    return "外部的"
                }
            },
            computed: {
                myData() {
                    return "helle myData"
                }
            }
        }
        var vm = new Vue({
            el: "#box",
            data: {
                nowIndex: 0
            },
            mixins: [obj],//将外部一个对象混入
            methods: {//vue自身的选项一样可以使用，不会被覆盖
                handleClick3() {
                    console.log("click3")
                },
                fn() {//同名方法会优先执行Vue内部的程序
                    return "自己的"
                }
            }
        })
    </script>
</body>

</html>